package oo

import (
	"errors"
	"github.com/elliotchance/pie/v2"
	"strings"
)

type SubstringV6 struct {
	String
}

func (o *SubstringV6) Ints() ([]int, error) {
	ss := o.split()

	var number Number
	for _, s := range ss {
		if !number.IsInt(s) {
			return nil, errors.New(s + " is not an integer")
		}
	}

	return pie.Map(ss, number.ToInt), nil
}

func (o *SubstringV6) split() []string {
	return strings.Split(o.value, ",")
}
